`
https://leetcode.cn/problems/search-a-2d-matrix-ii/
`

/**
 * @param {number[][]} matrix
 * @param {number} target
 * @return {boolean}
 */
var searchMatrix = function (matrix, target) {
  const m = matrix.length, n = matrix[0].length
  // 初始化在坐上角，规定只能向左或向下移动

  let i = 0, j = n - 1

  while (i < m && j >= 0) {
    if (matrix[i][j] === target) {
      return true
    }

    if (matrix[i][j] < target) {
      i++
    } else {
      j--
    }
  }

  return false
};